/*
 *  Copyright (C) 2017-present Albie Liang. All rights reserved.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */

package cc.suitalk.ipcinvoker.sample.nimble;

import cc.suitalk.ipcinvoker.IPCRemoteAsyncInvoke;
import cc.suitalk.ipcinvoker.IPCRemoteInvokeCallback;
import cc.suitalk.ipcinvoker.extension.XIPCInvoker;
import cc.suitalk.ipcinvoker.sample.service.PushProcessIPCService;
import cc.suitalk.ipcinvoker.tools.Log;
import cc.suitalk.ipcinvoker.type.IPCString;

/**
 * Created by albieliang on 2017/7/6.
 */

public class IPCInvokeSample_InvokeByType {

    public static final String TAG = "IPCSample.IPCInvokeSample_InvokeByType";

    public static void invokeIPCLogic() {
        TestType data = new TestType();
        data.key = "wx-developer";
        data.value = "AlbieLiang";
        XIPCInvoker.invokeAsync(PushProcessIPCService.PROCESS_NAME, data, IPCRemoteInvoke_PrintSomething.class, new IPCRemoteInvokeCallback<IPCString>() {

            @Override
            public void onCallback(IPCString data) {
                Log.i(TAG, "result : %s", data.value);
            }
        });
    }

    private static class IPCRemoteInvoke_PrintSomething implements IPCRemoteAsyncInvoke<TestType, IPCString> {

        @Override
        public void invoke(TestType data, IPCRemoteInvokeCallback<IPCString> callback) {
            callback.onCallback(new IPCString(data.key + ":" + data.value));
        }
    }
}
